package dao.impl;

import com.google.common.collect.ImmutableMap;
import dao.CouponDao;
import domain.Coupon;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * Created by aceyin on 15/6/27.
 */
@Repository
public class CouponDaoImpl extends BaseGenericDao<Coupon, Integer> implements CouponDao {
    @Override
    public Coupon findByCode(String code) {
        Map<String, Object> param = ImmutableMap.<String, Object>builder().put("code", code).build();
        return queryOne("find-coupon-by-code", param);
    }

    @Override
    public void activeCoupon(String code) {
        Map<String, Object> params = ImmutableMap.<String, Object>builder().put("code", code).build();
        update("active-coupon-by-code", params);
    }
}
